angular.module('todoApp').directive('todoBody', function() {
  return {
    templateUrl: './directives/todoBody.html',
    scope: {
      list: '=list',
      undo: '&onUndo',
      archive: '&onArchive',
      archiveAll: '&onArchiveAll'
    },
    link: function(scope) {
      scope.checkedList = [];
      scope.uncheckedList = [];
      scope.$watch('list', function() {
        scope.checkedList = scope.list.filter(item => item.checked);
        scope.uncheckedList = scope.list.filter(item => !item.checked);
      }, true); // 使用deep watch
    }
  };
});